import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class StudentGradeSystem {
    private static Map<String, Integer> grades = new HashMap<>();
    private static Scanner scanner = new Scanner(System.in);

    public static void recordGrade() {
        System.out.print("请输入学生姓名: ");
        String name = scanner.nextLine();
        System.out.print("请输入学生成绩: ");
        int grade = scanner.nextInt();
        scanner.nextLine(); // 清除换行符
        grades.put(name, grade);
        System.out.println("成绩记录成功！");
    }

    public static void queryGrade() {
        System.out.print("请输入学生姓名: ");
        String name = scanner.nextLine();
        if (grades.containsKey(name)) {
            System.out.println(name + "的成绩是: " + grades.get(name));
        } else {
            System.out.println("未找到该学生的成绩记录。");
        }
    }

    public static void main(String[] args) {
        while (true) {
            System.out.println("请选择操作:");
            System.out.println("1. 记录学生成绩");
            System.out.println("2. 查询学生成绩");
            System.out.println("3. 退出");
            int choice = scanner.nextInt();
            scanner.nextLine(); // 清除换行符
            switch (choice) {
                case 1:
                    recordGrade();
                    break;
                case 2:
                    queryGrade();
                    break;
                case 3:
                    System.out.println("谢谢使用！");
                    scanner.close();
                    System.exit(0);
                default:
                    System.out.println("无效的选择，请重新输入。");
            }
        }
    }
}